package orest.front.message;

import java.sql.Connection;

import net.ssta.common.LoginUser;
import net.ssta.core.base.SQLBuilderBase;
import net.ssta.core.web.RequestKit;



/**
 * 
 * @ClassName:
 * @Description: 
 * @author: 
 * @date: 
 * 
 */
public class MessageSql extends SQLBuilderBase
{
    /*
     * m_builder : 单例实例
     */
    private static MessageSql m_builder = new MessageSql();
    
    /**
     * @Title: getSQLBuilder
     * @Description: 获取实例
     * 
     * @param conn 数据库连
     * @return 单例实例
     */
    public static MessageSql getSQLBuilder(Connection conn)
    {
        return m_builder;
    }
    
    /**
     * 获取指定用户的留言信息
     * 
     * @param RequestKit
     * @return
     */
    public static String getMessageByUseridSql()
    {
        StringBuffer sb = new StringBuffer();
        sb.append("SELECT * FROM T_USERMESSAGE T WHERE USERID = '").append(LoginUser.getUserId()).append("' ORDER BY SUBMITDATE DESC");
        //sb.append("SELECT * FROM T_USERMESSAGE T WHERE USERID = '1' ORDER BY SUBMITDATE DESC");
        return sb.toString();
    }
    
    /**
     * 删除用户留言的sql
     * 
     * @param uuid:用户留言的唯一标识
     * 
     * @return：
     */
    public static String deleteMessageSql(String uuid)
    {
        StringBuffer sb = new StringBuffer();
        sb.append(" DELETE FROM T_USERMESSAGE WHERE ID ='").append(uuid).append("' ");
        return sb.toString();
    }
    
    /**
     * 根据用户留言uid获取详细信息
     * 
     * @param uuid:用户留言的唯一标识
     * 
     * @return：sql字符串
     */
    public static String getMessageInfoSql(String uuid)
    {
        StringBuffer sb = new StringBuffer();
        sb.append(" SELECT * FROM T_USERMESSAGE WHERE ID ='").append(uuid).append("' ");
        return sb.toString();
    }
    
    /**
     * 根据用户留言uid获取留言回复详细信息
     * 
     * @param uuid:用户留言的唯一标识
     * 
     * @return：sql字符串
     */
    public static String getMessagereplyInfoSql(String uuid)
    {
        StringBuffer sb = new StringBuffer();
        sb.append(" SELECT * FROM T_MESSAGEREPLY WHERE MESSAGEID ='").append(uuid).append("' ");
        return sb.toString();
    }
}
